/*
 *  Disc Catalog
 *  A little application to quickly catalog and find contents of your
 *  DVD archives.
 *
 *  Disc.m
 *  The root object of every disc scanned by the application.
 *
 *
 *  Created by Nicola Gigante on 20/12/08.
 *  Copyright (C) 2008  Nicola Gigante
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#import "Disc.h"


@implementation Disc

@synthesize path, label, isExplicit, catalog;

- (id) init
{
	self = [super initDirectoryWithName:@""];
	
	self.path = @"";
	self.icon = [[NSImage alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"disc" ofType:@"png"]];
	self.isExplicit = NO;
	self.label = @"";
	
	return self;
}

- (id) initWithDirectory:(File *)dir
{
	self = [super initDirectoryWithName:dir.name];
	self.size = dir.size;
	self.files = dir.files;
	self.visibleFiles = dir.visibleFiles;
	self.path = @"";
	self.icon = [[NSImage alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"disc" ofType:@"png"]];
	self.typeString = @"Disc";
	self.label = @"";
	[self setRoot: self];
	
	return self;
}

- (id) initWithCoder:(NSCoder *)decoder
{
	self = [super initWithCoder:decoder];
	self.path = [decoder decodeObjectForKey:@"path"];
	self.icon = [[NSImage alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"disc" ofType:@"png"]];
	self.isExplicit = [decoder decodeBoolForKey:@"isExplicit"];
	self.label = [decoder decodeObjectForKey:@"label"];
	[self setRoot:self];
	
	return self;
}

- (void) encodeWithCoder:(NSCoder *)encoder
{
	[super encodeWithCoder:encoder];
	[encoder encodeObject:self.path forKey:@"path"];
	[encoder encodeBool:self.isExplicit forKey:@"isExplicit"];
	[encoder encodeObject:self.label forKey:@"label"];
}

+ (Disc *) scanFromPath:(NSString *) path
{
	File *f = [File scanFromPath:path];
	Disc *d = [[Disc alloc] initWithDirectory:f];
	
	return d;
}

@end

@implementation File (labelsAdditions)

- (NSString *) label
{
	return @"";
}

@end



